<template>
  <!-- 电台排行榜 -->
  <div class="layoutBox">
    <div class="titleBox">电台排行榜</div>
    <ul class="newRcommendationBox">
      <router-link
        :to="{ name: 'radiostationdetail', query: { id: item.id } }"
        class="itemBox"
        tag="li"
        v-for="item in newRcommendationList"
        :key="item.id"
      >
        <img :src="item.picUrl" class="itemImg" alt="" />
        <div>
          <p class="itemName">{{ item.name }}</p>
          <p class="itemRcmdtext">{{ item.rcmdtext }}</p>
        </div>
      </router-link>
    </ul>
    <div class="pageBox">
      <el-pagination
        background
        layout="prev, pager, next"
        :total="total"
        :page-size="pagelimit"
        :current-page.sync="contnetPage"
        :hide-on-single-page="true"
        @current-change="pageNumChange"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
import { radioCharts } from "@/api";
export default {
  data() {
    return {
      newRcommendationList: [],
      total: 0,
      pagelimit: 20,
      contnetPage: 1,
    };
  },
  created() {
    this.getDate();
  },
  methods: {
    getDate() {
      radioCharts({
        cateId: this.$route.query.id,
        limit: this.pagelimit,
        offset: (this.contnetPage - 1) * this.pagelimit,
      }).then((res) => {
        this.newRcommendationList = res.djRadios;
        this.total = res.count;
        console.log(res);
      });
    },
    pageNumChange(num) {
      console.log(123, num);
      this.getDate();
    },
  },
};
</script>

<style lang="scss" scoped>
.layoutBox {
  margin-top: 35px;
  .titleBox {
    height: 40px;
    border-bottom: 2px solid #c20c0c;
    font-size: 24px;
    color: #333;
    span {
      float: right;
      font-size: 12px;
      margin-top: 14px;
      color: #666;
      cursor: pointer;
    }
  }
  .newRcommendationBox {
    display: flex;
    flex-wrap: wrap;
    .itemBox {
      width: 48%;
      padding: 20px 0;
      display: flex;
      cursor: pointer;
      border-bottom: 1px solid #e7e7e7;
      &:nth-of-type(even) {
        margin-left: 4%;
      }
      .itemImg {
        width: 120px;
        margin-right: 20px;
        height: 120px;
      }
      .itemName {
        margin: 16px 0 20px;
        font-size: 18px;
        color: #333;
        font-weight: 700;
      }
      .itemRcmdtext {
        line-height: 20px;
        color: #999;
      }
    }
  }
  .pageBox {
    text-align: center;
    margin-top: 20px;
  }
}
</style>